/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ch.simas.javaee6examples.web;

import ch.simas.javaee6examples.model.Employee;
import ch.simas.javaee6examples.service.EmployeeService;
import java.io.Serializable;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.enterprise.context.SessionScoped;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;

/**
 *
 * @author Simon
 */
@ManagedBean
@ViewScoped
public class ListBean implements Serializable {

    @EJB
    private EmployeeService employeeService;
    private List<Employee> list;

    @PostConstruct
    public void init() {
        list = employeeService.findAll();
    }

    public void delete(Employee employee) {
        employeeService.deleteEntity(employee);
        init();
    }

    public List<Employee> getList() {
        return list;
    }

    public void setList(List<Employee> list) {
        this.list = list;
    }
}
